package org.rambadger.command.providers;

import com.sun.jersey.spi.inject.InjectableProvider;
import com.sun.jersey.spi.inject.SingletonTypeInjectableProvider;

import javax.ws.rs.core.Context;
import java.lang.reflect.Type;

/**
 * Provides a slightly more elegant way to wrap single object instances in a {@link SingletonTypeInjectableProvider}
 */
public class SingletonInjectorFactory {
    /**
     * Wraps a singleton object in an injectable provider.
     *
     * @param klass The type that you want the singleton to be injected into
     * @param singleton the singleton object
     * @return the provider
     */
    public static <T> InjectableProvider<Context, Type> getProvider(Class<T> klass, T singleton) {
        return new SingletonTypeInjectableProvider<Context, T>(klass, singleton) {};
    }
}

